{{define "title"}}{{.resource.title}} {{end}}
{{define "seo"}}<meta name="keywords" content="{{.setting.SeoKeywords}}">
<meta name="description" content="{{substring .resource.content 200 ""}}">{{end}}
{{define "content"}}

{{include "common/suspend.html" .}}

<div class="row">
	<div class="col-md-9 col-sm-6">
		<div class="sep20"></div>
		<ol class="breadcrumb">
			<li><a href="/">首页</a></li>
			<li><a href="/resources">资源</a></li>
			<li><a href="/resources/cat/{{.resource.catid}}">{{.resource.catname}}</a></li>
		</ol>
		<div class="page">
			<div class="box_white" style="overflow: visible;">
				<div class="title">
					<div class="pull-right">
						<a href="/user/{{.resource.user.Username}}" title="{{.resource.user.Username}}">
							<img src="{{gravatar .resource.user.Avatar .resource.user.Email 62 .is_https}}" alt="{{if .resource.user.Name}}{{.resource.user.Name}}{{else}}{{.resource.user.Username}}{{end}}" width="62px" height="62px">
						</a>
					</div>
					<h1>
						{{.resource.title}}
					</h1>
					<small class="c9">
						<a href="/user/{{.resource.user.Username}}">{{.resource.user.Username}}</a> · <span title="{{.resource.ctime}}" class="timeago"></span> · {{add .resource.viewnum 1}} 次点击 &nbsp; &nbsp;
						{{if canEdit .me .resource}}
						<a class="op" href="/resources/modify?id={{.resource.id}}" title="编辑">编辑</a>
						{{end}}
					</small>
				</div>
				{{if gt (distanceDay .resource.ctime) 100 }}
				<div class="outdated">这是一个分享于 <span title="{{.resource.ctime}}" class="timeago"></span> 的资源，其中的信息可能已经有所发展或是发生改变。</div>
				{{end}}
				<div class="cell">
					<div class="content">{{if eq .resource.form "只是链接"}}传送门： {{if hasPrefix .resource.url "/r/golang/"}}https://reddit.com{{end}}{{.resource.url}}{{else}}{{.resource.content}}{{end}}</div>
				</div>

				<!-- 加群等 -->
				{{include "common/promotion.html" .}}

				<div class="content-buttons">
					<div class="pull-right c9 f11" style="line-height: 12px; padding-top: 3px; text-shadow: 0px 1px 0px #fff;">{{add .resource.viewnum 1}} 次点击 &nbsp;{{if .resource.likenum}}∙&nbsp; {{.resource.likenum}} 赞 &nbsp; {{end}}</div>
					<a class="tb collect" href="javascript:;" title="{{if .hadcollect}}取消收藏{{else}}加入收藏{{end}}" data-objid="{{.resource.id}}" data-objtype="2" data-collect="{{.hadcollect}}">{{if .hadcollect}}取消收藏{{else}}加入收藏{{end}}</a>
					<a href="javascript:" class="tb weibo-btn">微博</a>
					<div id="content-thank">
						<a class="tb" href="javascript:;" title="{{if .likeflag}}取消赞{{else}}赞{{end}}" data-objid="{{.resource.id}}" data-objtype="2" data-flag="{{.likeflag}}">{{if .likeflag}}取消赞{{else}}赞{{end}}</a>
					</div>
				</div>
			</div>
			<!-- content END -->
			<div class="sep20"></div>

			<!-- 评论列表 -->
			<div id="replies" class="box_white">
				<div class="cell">
					<div class="pull-right" style="margin: -3px -5px 0px 0px;">
					{{if .resource.tags}}
						{{$tags := explode .resource.tags ","}}
						{{range $tags}}
						<a href="/tag/{{.}}" class="tag"><li class="fa fa-tag"></li> {{.}}</a>
						{{end}}
					{{end}}
					</div>
					<span class="c9"><span class="cmtnum">{{.resource.cmtnum}}</span> 回复 {{if .resource.cmtnum}}&nbsp;<strong class="snow">|</strong> &nbsp;直到 {{end}}</span>
				</div>
				{{include "common/comment-page.html" .}}
				<div class="comment-list cell" data-objid="{{.resource.id}}" data-objtype="2" {{if .me.Uid}}data-username="{{.me.Username}}" data-uid="{{.me.Uid}}" data-avatar="{{gravatar .me.Avatar .me.Email 48 .is_https}}"{{end}}>
					<div class="words hide"><div class="text-center">暂无回复</div></div>
				</div>
				{{include "common/comment-page.html" .}}
			</div>

			<!-- 评论框 -->
			{{template "comment" .}}

			{{include "common/view_stat.html" .}}
		</div>
	</div>
	<div class="col-md-3 col-sm-6">
		<div class="sep20"></div>

		{{include "common/my_info.html" .}}

		{{if .pos_ad.right1}}
		<div class="box_white sidebar" id="ad-right1">
			{{if eq .pos_ad.right1.AdType 0}}
				{{noescape .pos_ad.right1.Code}}
			{{end}}
		</div>
		{{end}}

		{{include "sidebar/view_rank.html" (parseJSON `{"rank_title":"今日阅读排行","objtype":2,"limit":10,"rank_type":"today"}`)}}

		{{if .pos_ad.right2}}
		<div class="box_white sidebar" id="ad-right2">
			{{if eq .pos_ad.right2.AdType 0}}
				{{noescape .pos_ad.right2.Code}}
			{{end}}
		</div>
		{{end}}

		{{include "sidebar/view_rank.html" (parseJSON `{"rank_title":"一周阅读排行","objtype":2,"limit":10,"rank_type":"week"}`)}}

		{{include "sidebar/topic.html" .}}

	</div>
</div>
{{end}}
{{define "css"}}
{{include "cssjs/prism.css.html" .}}
<style type="text/css">
.sb-author .sb-content .avatar {margin: 0 10px 10px;}
.edit-info {color: #3c763d;background-color: #dff0d8;border-color: #d6e9c6; margin:0 10px;}
</style>
{{end}}
{{define "js"}}

{{include "cssjs/prism.js.html" .}}
<script type="text/javascript" src="{{.static_domain}}/static/dist/js/resources.min.js"></script>

<script type="text/javascript">
// 需要加载的侧边栏
SG.SIDE_BARS = [
	"/topics/recent",
	"/articles/recent",
	"/rank/view"
];

var keyprefix = 'resource';
var objid = {{.resource.id}};

$(function(){
	new SG.Resources().parseContent($('.page .content'));

	// 文本框自动伸缩
	$('.need-autogrow').autoGrow();

	loadComments();

	// 链接，add target=_blank
	$('#wrapper .content').on('mousedown', 'a', function(evt){
		var url = $(this).attr('href');
		$(this).attr('target', '_blank');
	});

	$('.weibo-btn').on('click', function(evt) {
		evt.preventDefault();

		window.open('http://service.weibo.com/share/share.php?url=http{{if .is_https}}s{{end}}://{{.setting.Domain}}/resources/{{.resource.id}}&title='+encodeURIComponent('{{.setting.Name}} - {{.resource.title}} by {{.resource.user.Username}} #golang#'), '_blank', 'width=550,height=370');
	});
});
</script>

{{if .pos_ad.right1}}
	{{if eq .pos_ad.right1.AdType 1}}
		{{noescape .pos_ad.right1.Code}}
	{{end}}
{{end}}

{{if .pos_ad.right2}}
	{{if eq .pos_ad.right2.AdType 1}}
		{{noescape .pos_ad.right2.Code}}
	{{end}}
{{end}}

{{end}}
